Gets an example of the value of DataRow[]

  • 2020-12-10 00:41:02
  • OfStack

First, DataRow[] dr = dt.Select(" t1= 'a' "); The result is 1 array, and you just loop through the array.
 
string x=""; 
if (dr.Length > 0) 
{ 
foreach (DataRow drN in dr) 
{ 
x+=drN["t2"]; // After the loop obtains the filter conditions  t2 The value of the column  
} 
} 

Note that the value can also be obtained by specifying which line: if you want to obtain the filtered value for the first line, you can do so in the following sentence
string x=dr[0]["t2"].Tostring(); // Gets the value of the filtered t2 field in line 1.

Related articles: